//
//  mima.m
//  class
//
//  Created by 钟纪旺 on 16/4/15.
//  Copyright © 2016年 zjw. All rights reserved.
//


#import "mima.h"

@implementation mima
{
    NSString *name;
    //定义变量
    NSString *mima2;
    //定义变量
}

- (void)getName
//函数返回值 函数名
{
    NSLog(@"请输入用户名：");
    
    char* name_ = malloc(20);
    scanf("%s", name_);
    name = [[NSString alloc] initWithCString:
            name_ encoding:NSUTF8StringEncoding];
    //把c语言转化成oc语言
    [self getPasswd];
    //使用 另一个函数
}
- (void)getPasswd
{
    NSLog(@"请输入密码：");
    char* pass = malloc(20);
    //申请空间
    scanf("%s", pass);
    mima2 = [[NSString alloc] initWithCString:pass encoding:NSUTF8StringEncoding];
    //把c语言转化成oc语言
    if ([name isEqualToString:@"zjw"] && [mima2 isEqualToString:@"789"]) {
        NSLog(@"登录成功！");
        [self.delegate loginWithName:name mima2:mima2 success:YES];
    }else{
        NSLog(@"登录失败！");
        [self.delegate loginWithName:name mima2:mima2 success:NO];
    }
}

@end

